<?php
class M_tags extends Module {
  public function main() {
    if ( !Site::$ajax ) {
      $list = new ListGeneric();
      $list->sql = "
        SELECT `tags_names`.`name`, `tags_names`.`permalink`, `tags`.`id`
        FROM `tags`
        INNER JOIN `tags_names`
          ON ( `tags`.`name` = `tags_names`.`id` )
        WHERE `tags`.`id` = `tags_names`.`tag`
        ORDER BY `tags_names`.`name`";
      $list->load();
      $list->template = 'pan_tags';
      $tmp = $list->get_html();
      return $tmp;
} else {
  $sql = "
        SELECT `tags_names`.`name`, `tags_names`.`permalink`, `tags`.`id`
        FROM `tags`
        INNER JOIN `tags_names`
          ON ( `tags`.`name` = `tags_names`.`id` )
        WHERE `tags`.`id` = `tags_names`.`tag`
        ORDER BY `tags_names`.`name`";
  $res = $db->q( $sql );

  while ( $r = $res->assoc() ) {
    $tag = new Template( "pan_tag" );
    $tag->ins( "name",     $r['name'] );
    $tag->ins( "id",       $r['id'] );
    $tag->ins( "left",     1 );
    echo $tag;
  }
  
}

  }
}

?>